<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/9/13
  Time: 10:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../common/include.jsp" %>
<html>
<head>
    <title>Title</title>
    <script>
        $(function () {
            //时间选择器
            laydate.render({
                elem: '#beginTime'
                , type: 'datetime'
            });
            //时间选择器
            laydate.render({
                elem: '#endTime'
                , type: 'datetime'
            });
        });
    </script>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <form class="form-horizontal" id="demandForm" name="demandForm">
        <input type="hidden" id="demId" name="demId" value="${tDemandSource.id}">
        <input type="hidden" id="status" name="status" value="${tDemandSource.status}">
        <input type="hidden" id="isReceive" name="isReceive" value="${isReceive}">
        <div class="tabs-container">
            <fieldset>
                <div class="form-group">
                    <label class="col-sm-2 control-label">问题类型：</label>
                    <div class="col-sm-2">
                        <select id="demandType"
                                name="conditions['demandType']" class="form-control"
                                required="" aria-required="true">
                            <option value="0"
                            >全部
                            </option>
                            <option value="1"
                            >BUG
                            </option>
                            <option value="2"
                            >需求
                            </option>
                            <option value="3"
                            >操作
                            </option>
                        </select>
                    </div>
                    <label class="col-sm-2 control-label">问题产品：</label>
                    <div class="col-sm-2">
                        <select id="demandProduct" name="conditions['demandProduct']"
                                class="form-control"
                                required="" aria-required="true">
                            <option value="0"
                                    <c:if test="${pages.conditions.demandProduct == 0}">selected</c:if>>
                                全部
                            </option>
                            <option value="1"
                                    <c:if test="${pages.conditions.demandProduct == 1}">selected</c:if>>
                                中环E家-房源
                            </option>
                            <option value="2"
                                    <c:if test="${pages.conditions.demandProduct == 2}">selected</c:if>>
                                中环E家-客源
                            </option>
                            <option value="3"
                                    <c:if test="${pages.conditions.demandProduct == 3}">selected</c:if>>
                                中环E家-数据
                            </option>
                            <option value="4"
                                    <c:if test="${pages.conditions.demandProduct == 4}">selected</c:if>>
                                中环E家-交易
                            </option>
                            <option value="5"
                                    <c:if test="${pages.conditions.demandProduct == 5}">selected</c:if>>
                                中环E家-财务
                            </option>
                            <option value="6"
                                    <c:if test="${pages.conditions.demandProduct == 6}">selected</c:if>>
                                中环E家-行政
                            </option>
                            <option value="7"
                                    <c:if test="${pages.conditions.demandProduct == 7}">selected</c:if>>IOS端
                            </option>
                            <option value="8"
                                    <c:if test="${pages.conditions.demandProduct == 8}">selected</c:if>>
                                Android端
                            </option>
                            <option value="9"
                                    <c:if test="${pages.conditions.demandProduct == 9}">selected</c:if>>网站
                            </option>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">录入开始时间：</label>
                    <div class="col-sm-2">
                        <input readonly id="beginTime"
                               name="conditions['beginTime']"
                               value="${pages.conditions.beginTime}"
                               type="text" size="8"
                               class="form-control"></div>
                    <label class="col-sm-2 control-label">录入结束时间：</label>
                    <div class="col-sm-2">

                        <input readonly name="conditions['endTime']" id="endTime"
                               type="text" size="8"
                               value="${pages.conditions.endTime}"
                               class="form-control">
                    </div>
                </div>
            </fieldset>
            <fieldset>
                <div class="form-group">
                    <div class="col-sm-2" style="text-align: center;">

                        <input value="提交" class="btn  btn-primary" type="button" id="submitBtn">
                        <button id="closeBut" onclick="closeWin()" class="btn  btn--white" type="button">关闭</button>
                    </div>
                </div>
            </fieldset>
        </div>
    </form>
</div>


<script>
    function closeWin() {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    }


    $("#submitBtn").click(function () {
        var remark = $("#remark").val();
        var isReceive = $("#isReceive").val();
        var demandId = $("#demId").val();
        var status = $("#status").val();
        var currentPrincipal = $("#currentPrincipal").find("option:selected").text();
        var currentPrincipalId = $("#currentPrincipal").val();


        var args = {
            "status": status,
            "demandId": demandId,
            "isReceive": isReceive,
            "remark": remark,
            "currentPrincipal": currentPrincipal,
            "currentPrincipalId": currentPrincipalId
        }

        var url = "checkDemandPage.html";

        //计划审批使用另外一个action
        if (status == 7) {
            url = "checkPlanPage.html";
        }
        //加载进度条
        layer.load(2, {
            shade: [0.2, '#999999'] //0.1透明度的白色背景
        });
        $.post(url, args, function (data) {
            data = jQuery.parseJSON(data);
            //保存成功
            if (data.code == 1) {
                layer.closeAll('loading');
                layer.alert(data.msg,
                    function () {
                        parent.location.reload();
                    });


            } else {
                //失败
                layer.alert("失败");
                layer.closeAll('loading');
            }
        });

    });

</script>
</body>
</html>
